package org.sy.lab.Java7并发编程实战.六并发集合.七使用原子变量;

import java.util.concurrent.atomic.AtomicLong;

public class Account {
	private AtomicLong balance;
	public Account() {
		balance = new AtomicLong();
	}
	public long getBalanec() {
		return balance.get();
	}
	public void setBalance(long balance) {
		this.balance.set(balance);
	}
	public void addAmount(long amount) {
		this.balance.getAndAdd(amount);
	}
	public void subtractAmount(long amount) {
		this.balance.getAndAdd(-amount);
	}
}
